<?php
namespace AuctionCore\AuctionOrder;
use AuctionCore\CarResource\Car;
//
// +------------------------------------------------------------------------+
// | PHP Version 5.4                                                        |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | 世纪车来车往(北京）网络科技有限公司 版权所有！                         |
// | TEL:010-63732365  HOTLINE:400-6688-365  EMAIL:clcw@clcw.com.cn         |
// | $Revision: 1.0 $                                                       |
// +------------------------------------------------------------------------+
// | Author: songaimin@clcw.com.cn  Blog:http://blog.csdn.net/samxx8        |
// +------------------------------------------------------------------------+
//


/**
* 拍单车主人工确认
* @author       爱民
*/
class OwnerConfirm extends AuOrder
{
   
    
    /**
    * 同意低于保留价，出售！ 
    * @param    array $booking_info    同意卖车后的预约信息[预约时间，服务方式，预约地址，备注]
    * @return   void 
    */
    public function agree($confirm_info)
    {
        $confirm_info['order_id'] = $this->auction_order_id;
        $now = date("Y-m-d H:i:s",time());
        $confirm_info['createtime'] = $now;
        $confirm_info['result'] = 1;
        $m = M('owner_confirm_log');
        $insertID = $m->add($confirm_info);
        if(intval($insertID)>0){
            //更拍单为"待签约"
            $this->update(array('au_status'=>6));
        }
    }
    
    /**
    * 不同意低于保留价成交，就选择重拍：
    * 置：拍单失败_客户要求重拍
    * 置：车源状态为“流拍”
    * @param    string $remark    重拍备注
    * @return   void
    */
    public function re_auction($remark)
    {
        $confirm_info['order_id'] = $this->auction_order_id;
        $now = date("Y-m-d H:i:s",time());
        $confirm_info['createtime'] = $now;
        $confirm_info['result'] = 3;  
        $confirm_info['remark'] = $remark;          
        $m = M('owner_confirm_log');
        $ok = $m->add($confirm_info);
        if($ok){
            //更改车源“待重拍” 
            $au_detail = $this->detail();
            $car = new Car($au_detail['car_id']);
            $ok = $car->update(array('car_status'=>7));//待重拍

            //更改拍单“拍单失败_车主要求重拍"
            $ok = $this->update(array('au_status'=>12,'au_fail_type'=>1));
        }
    }
    
    /**
    * 继续跟踪
    * @param    string $continue_case    继续跟踪原因及备注
    * @param    string $next_datetime    下次跟踪时间
    * @return   void
    */
    public function con_trace($continue_case, $next_datetime)
    {
        $confirm_info['order_id'] = $this->auction_order_id;
        $now = date("Y-m-d H:i:s",time());
        $confirm_info['createtime'] = $now;
        $confirm_info['result'] = 2;  
        $confirm_info['remark'] = $continue_case;  
        $confirm_info['next_trace_time'] = $next_datetime;  
        $m = M('owner_confirm_log');
        $m->add($confirm_info);
    }
    
    /**
    * 不卖了
    * @param    string $remark    备注
    * @return   void
    */
    public function refuse_sold($remark)
    {
        $confirm_info['order_id'] = $this->auction_order_id;
        $now = date("Y-m-d H:i:s",time());
        $confirm_info['createtime'] = $now;
        $confirm_info['result'] = 4;  
        $confirm_info['remark'] = $remark;          
        $m = M('owner_confirm_log');
        $ok = $m->add($confirm_info);
        if($ok){
            //更改车源“交易失败” 
            $au_detail = $this->detail();
            $car = new Car($au_detail['car_id']);
            $ok = $car->update(array('car_status'=>8));

            //更改拍单“拍单失败_车主不卖了"
            $ok = $this->update(array('au_status'=>12,'au_fail_type'=>2));
        }
    }
        
}

?>